package org.ruiyichen.guizhou.agr.ui.mineview;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.widget.TextView;

import org.ruiyichen.guizhou.agr.R;


public class BallProgressDialog extends Dialog {

    private Context context = null;
    private static BallProgressDialog customProgressDialog = null;

    public BallProgressDialog(Context context) {
        super(context);
        this.context = context;
    }

    public BallProgressDialog(Context context, int theme) {
        super(context, theme);
        this.context = context;
    }

    public static BallProgressDialog createDialog(Context context) {
        customProgressDialog = new BallProgressDialog(context, R.style.CustomProgressDialog);
        customProgressDialog.setContentView(R.layout.dialog_ball_progress);
        customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;

        return customProgressDialog;
    }

    public void onWindowFocusChanged(boolean hasFocus) {

        if (customProgressDialog == null) {
            return;
        }

//        ImageView imageView = (ImageView) customProgressDialog.findViewById(R.id.brpb_loading);
//        RotateAnimation rotateAnimation =new RotateAnimation(-8.0f, 8.0f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF, 0.2f);
//        rotateAnimation.setDuration(300);
//        rotateAnimation.setRepeatCount(Animation.INFINITE);
//        rotateAnimation.setRepeatMode(Animation.REVERSE);
//        imageView.setAnimation(rotateAnimation);
//        rotateAnimation.start();
    }

    /**
     * [Summary]
     * setTitile 标题
     *
     * @param strTitle
     * @return
     */
    public BallProgressDialog setTitile(String strTitle) {
        return customProgressDialog;
    }

    /**
     * [Summary]
     * setMessage 提示内容
     *
     * @param strMessage
     * @return
     */
    public BallProgressDialog setMessage(String strMessage) {
        TextView tvMsg = (TextView) customProgressDialog.findViewById(R.id.tv_loading_msg);

        if (tvMsg != null) {
            tvMsg.setText(strMessage);
        }

        return customProgressDialog;
    }
}  